﻿using System;

namespace Infrastructure.ElasticSearch.ParentChilds
{
    public class ConditionContext<T>
    where T : class
    {
        private readonly ConditionBuilder<T> _mustBuilder;
        private readonly ConditionBuilder<T> _mustNotBuilder;
        private readonly ConditionBuilder<T> _shouldBuilder;

        public ConditionContext()
        {
            _mustBuilder = new ConditionBuilder<T>();
            _mustNotBuilder = new ConditionBuilder<T>();
            _shouldBuilder = new ConditionBuilder<T>();
        }

        public ConditionBuilder<T> MustBuilder => _mustBuilder;

        public ConditionBuilder<T> MustNotBuilder => _mustNotBuilder;

        public ConditionBuilder<T> ShouldBuilder => _shouldBuilder;

        public void Must(Func<ConditionBuilder<T>, ConditionBuilder<T>> must)
        {
            must.Invoke(_mustBuilder);
        }

        public void MustNot(Func<ConditionBuilder<T>, ConditionBuilder<T>> mustNot)
        {
            mustNot.Invoke(_mustNotBuilder);
        }

        public void Should(Func<ConditionBuilder<T>, ConditionBuilder<T>> should)
        {
            should.Invoke(_shouldBuilder);
        }
    }
}